package symbol;

public class LoopCounter {
	java.util.Stack<Integer> counter = new java.util.Stack<Integer>();
	
	public LoopCounter() { counter.push(new Integer(0)); }
	public void beginLoop() {
		Integer x = counter.pop();
		counter.push(new Integer(x + 1));
	}
	public void endLoop() {
		Integer x = counter.pop();
		counter.push(new Integer(x - 1));
	}
	
	public void beginFunction() {
		counter.push(new Integer(0));
	}
	
	public void endFunction() {
		counter.pop();
	}
	
	public boolean isInLoop() {
		return (counter.peek().intValue() != 0);
	}
}
